using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class ARC_OedetMap : EntityTypeConfiguration<ARC_Oedet>
    {
        public ARC_OedetMap()
        {
            // Primary Key
            this.HasKey(t => t.TRANSID);

            // Properties
            this.Property(t => t.TYPE)
                .IsRequired()
                .IsFixedLength()
                .HasMaxLength(1);

            this.Property(t => t.NUMBER)
                .IsRequired()
                .HasMaxLength(8);

            this.Property(t => t.ITEM)
                .IsRequired()
                .HasMaxLength(10);

            this.Property(t => t.LOCATION)
                .HasMaxLength(3);

            this.Property(t => t.EXPDATE)
                .HasMaxLength(6);

            this.Property(t => t.PONUM)
                .HasMaxLength(7);

            this.Property(t => t.TRANSID)
                .HasDatabaseGeneratedOption(DatabaseGeneratedOption.None);

            this.Property(t => t.File_Primary_Key)
                .HasMaxLength(10);

            this.Property(t => t.MasterItem)
                .HasMaxLength(10);

            this.Property(t => t.whosmakethisdiscount)
                .HasMaxLength(50);

            // Table & Column Mappings
            this.ToTable("ARC_Oedet");
            this.Property(t => t.TYPE).HasColumnName("TYPE");
            this.Property(t => t.NUMBER).HasColumnName("NUMBER");
            this.Property(t => t.ITEM).HasColumnName("ITEM");
            this.Property(t => t.LOCATION).HasColumnName("LOCATION");
            this.Property(t => t.QTYSHIP).HasColumnName("QTYSHIP");
            this.Property(t => t.QTYORDER).HasColumnName("QTYORDER");
            this.Property(t => t.COST).HasColumnName("COST");
            this.Property(t => t.NOTES).HasColumnName("NOTES");
            this.Property(t => t.EXPDATE).HasColumnName("EXPDATE");
            this.Property(t => t.PONUM).HasColumnName("PONUM");
            this.Property(t => t.ENTRY_DATE).HasColumnName("ENTRY_DATE");
            this.Property(t => t.ITEMTYPE).HasColumnName("ITEMTYPE");
            this.Property(t => t.CURRENCY).HasColumnName("CURRENCY");
            this.Property(t => t.EXTENDACCT).HasColumnName("EXTENDACCT");
            this.Property(t => t.PRICEACCT).HasColumnName("PRICEACCT");
            this.Property(t => t.TRANSID).HasColumnName("TRANSID");
            this.Property(t => t.DISCPERC).HasColumnName("DISCPERC");
            this.Property(t => t.BILLORDER).HasColumnName("BILLORDER");
            this.Property(t => t.USERID).HasColumnName("USERID");
            this.Property(t => t.KACT).HasColumnName("KACT");
            this.Property(t => t.AREACT).HasColumnName("AREACT");
            this.Property(t => t.ORACT).HasColumnName("ORACT");
            this.Property(t => t.LACT).HasColumnName("LACT");
            this.Property(t => t.RACT).HasColumnName("RACT");
            this.Property(t => t.PATAMTACT).HasColumnName("PATAMTACT");
            this.Property(t => t.INS1AMTACT).HasColumnName("INS1AMTACT");
            this.Property(t => t.INS2AMTACT).HasColumnName("INS2AMTACT");
            this.Property(t => t.DISCOUNTA).HasColumnName("DISCOUNTA");
            this.Property(t => t.AACT).HasColumnName("AACT");
            this.Property(t => t.NACT).HasColumnName("NACT");
            this.Property(t => t.File_Primary_Key).HasColumnName("File Primary Key");
            this.Property(t => t.OPERATIONSERIAL).HasColumnName("OPERATIONSERIAL");
            this.Property(t => t.EXPIRYDATE).HasColumnName("EXPIRYDATE");
            this.Property(t => t.CONSULTATION).HasColumnName("CONSULTATION");
            this.Property(t => t.Ins1Perc).HasColumnName("Ins1Perc");
            this.Property(t => t.Ins2Perc).HasColumnName("Ins2Perc");
            this.Property(t => t.MasterItem).HasColumnName("MasterItem");
            this.Property(t => t.Req_test_id).HasColumnName("Req_test_id");
            this.Property(t => t.operate_id).HasColumnName("operate_id");
            this.Property(t => t.MsterlstPrice).HasColumnName("MsterlstPrice");
            this.Property(t => t.TotalMsterlstPrice).HasColumnName("TotalMsterlstPrice");
            this.Property(t => t.Amountbeforediscount).HasColumnName("Amountbeforediscount");
            this.Property(t => t.ismaster).HasColumnName("ismaster");
            this.Property(t => t.Hospital1).HasColumnName("Hospital1");
            this.Property(t => t.Hospital2).HasColumnName("Hospital2");
            this.Property(t => t.masterid).HasColumnName("masterid");
            this.Property(t => t.department).HasColumnName("department");
            this.Property(t => t.AutoInsert).HasColumnName("AutoInsert");
            this.Property(t => t.APPROVED_INS1AMT).HasColumnName("APPROVED_INS1AMT");
            this.Property(t => t.APPROVED_INS2AMT).HasColumnName("APPROVED_INS2AMT");
            this.Property(t => t.whosmakethisdiscount).HasColumnName("whosmakethisdiscount");
            this.Property(t => t.OrderID).HasColumnName("OrderID");
            this.Property(t => t.FromOrderEntry).HasColumnName("FromOrderEntry");

            // Relationships
            this.HasRequired(t => t.ARC_Oe)
                .WithMany(t => t.ARC_Oedet)
                .HasForeignKey(d => new { d.TYPE, d.NUMBER });
            this.HasRequired(t => t.Item1)
                .WithMany(t => t.ARC_Oedet)
                .HasForeignKey(d => d.ITEM);
            this.HasRequired(t => t.Item2)
                .WithMany(t => t.ARC_Oedet1)
                .HasForeignKey(d => d.ITEM);

        }
    }
}
